<%@ page language="java" contentType="text/html; charset=UTF-8" pageEncoding="UTF-8"%>
<!DOCTYPE html>
<html lang="zh-CN">
<head>
	<%@ include file="/static/commom/head-import.jsp" %>
	<title>测试页面</title>
	
</head>
<body>
	<div class="container">
		请输入名称：<input type="text" id="name" name="name">
		<button type="button" id="submit" >提交</button>
	</div>
</body>

<script type="text/javascript">
	var testObject = testObject||{};
	testObject.submit = function(){
		var name = $("#name").val();
		var url = "/api/test/test";
		var  formData = {
			name:name
		};
/* 		$.post(url,formData,function(result){
			if(result){
				if(result.status==1){
					alert("提交成功");
				}
			}
		}); */
		$.ajax({
	       	type: 'post',	//提交类型
	       	url: url,		//webservice处理路径
	       	data: formData,	//提交的数据
	       	dataType:'json',	//提交数据的类型
	       	contentType: 'application/json',//接收数据的类型
	       	success: function (result) {	//成功的回调函数
    	   		if(result){
					if(result.status==1){
						alert("提交成功");
					}
				}
	       	},
	       	error: function(result){
	       		alert("未知错误");
	       	}
	   	});
	};
	
	$(function(){
		$("#submit").on("click",testObject.submit);
	});
</script>

</html>